package com.shycloud.mido.task.reward;

import com.shycloud.mido.task.api.entity.BasicGoodsInfo;
import com.shycloud.mido.task.mapper.BasicGoodsInfoMapper;
import com.shycloud.mido.task.mapper.SmMemberNoticeMapper;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;

@Component("4")
@AllArgsConstructor
public class RewardOnlineCourse extends RewardAbstract {

	/** 商品信息 mapper */
	private BasicGoodsInfoMapper goodsInfoMapper;
	/** 通知模块 mapper */
	private SmMemberNoticeMapper noticeMapper;

	@Override
	public boolean getReward(Integer orgId, String memberId, Integer goodsId) {

		//获取应领取的在线课时长
		BasicGoodsInfo basicGoodsInfo = goodsInfoMapper.selectById(goodsId);

		Integer onlineCount = basicGoodsInfo.getUnitCount();

		return noticeMapper.addOnlineCourse(orgId, onlineCount) == 1;

	}
}
